#ifndef TCPFORWARD_H
#define TCPFORWARD_H

#include <QObject>
#include <QTcpSocket>
#include <QTcpServer>

class TcpForward : public QObject
{
    Q_OBJECT
public:
    explicit TcpForward(QTcpSocket *clientSocket, QString serverIpAddr, unsigned short serverPortNum, QObject *parent = nullptr);
    ~TcpForward();

signals:
    void disconnect(TcpForward *forward);
    void uploadBytes(int nBytes);
    void downloadBytes(int nBytes);

public slots:
    void on_clientReadyRead();
    void on_clientDisconnect();
    void on_serverReadyRead();
    void on_serverDisconnect();
    void on_serverError(QAbstractSocket::SocketError socketError);

private:
    QTcpSocket *clientSd = nullptr;
    QTcpSocket *serverSd = nullptr;
    QString serverIp;
    unsigned short serverPort;
};

#endif // TCPFORWARD_H
